var isInit=true
function searchData(page) {
    var start_time = $('input.start_time').val()
    var end_time = $('input.end_time').val()
    $.get('searchStatistics', {
        start_time: start_time,
        end_time: end_time,
        page:page,
        size:10
    }, function (res) {
        if (res.status != 1) {
            alert(res.msg)
            return
        }
        $('#airborne .content').html('')
        $('#airborne .content').append(template('tpllist', res.data))
        if (res.data.total_count) {
            $('.dataCount>span').html('10/' + res.data.total_count)
        }
        if (isInit) {
            isInit = false
            setPage(res.data.total_count)
        }
    })
}
searchData(1)
var download = function () {
    var start_time = $('input.start_time').val()
    var end_time = $('input.end_time').val()
    if (start_time == '' || end_time == '') {
        alert('请选择正确的时间')
        return
    }
    var url = 'downloadBiBeanReport?start_time=' + start_time + '&end_time=' + end_time
    window.open(url)
}

//搜索按钮
function  search() {
    isInit=true;
    searchData(1)
}
//设置翻页插件
function setPage(size) {
    $('#page').pagination({
        pageCount: (function () {
            if (size % 10 == 0) {
                return size / 10
            }
            return Math.floor(size / 10 + 1)
        })(),
        jump: true,
        coping: true,
        homePage: '首页',
        endPage: '尾页',
        prevContent: '上页',
        nextContent: '下页',
        callback: function (api) {
            searchData(api.getCurrent())
        }
    });
}